const mockjs = require('mockjs');

const data = {
  'list|1-10': [
    {
      'id|+1': 1,
      'name': '@cname',
      'age|1-100': 1,
      'email': '@email',
      'phone': /^1[34578]\d{9}$/,
      'address': '@region'
    }
  ]
};

const result = mockjs.mock(data);
console.log(result);

// 生成一个随机数
const randomNum = mockjs.Random.integer(1, 100);
console.log(randomNum);

// 生成一个随机字符
const randomChar = mockjs.Random.character('lower', 1);
console.log(randomChar);

// 生成一个随机图片
const randomImg = mockjs.Random.image('200x100', '#000', 'Hello Mock.js');
console.log(randomImg);

const randomParagraph = mockjs.Random.paragraph();

const randomSentence = mockjs.Random.sentence();

const randomWord = mockjs.Random.word();
console.log('randomWord', randomWord);

// 生成一个随机时间
const randomTime = mockjs.Random.date('T');
console.log(randomTime);

// 生成一个随机布尔值
const randomBoolean = mockjs.Random.boolean();
console.log(randomBoolean);

// 定义一个对象模板
const objectTemplate = {
  id: '@guid',
  name: '@cname',
  age: '@integer(18, 50)',
  email: '@email',
  address: '@county(true)'
};
// 使用 Mock.mock() 方法生成一个随机对象
const randomObject = mockjs.mock(objectTemplate);
console.log(randomObject);

// 生成一个随机浮点数
const randomFloat = mockjs.Random.float(1, 100, 2, 2);
console.log(randomFloat);

// // 生成一个随机数组
// const randomArray = mockjs.Random.array(1, 10);
// console.log(randomArray);

// 生成一个随机对象
// const randomObject = mockjs.Random.object({
//   'id': '@id',
//   'name': '@name',
//   'age': '@integer(1, 100)',
//   'email': '@email',
//   'phone': /^1[34578]\d{9}$/,
//   'address': '@region'
// });
// console.log(randomObject);

// 生成一个随机字符串
const randomString = mockjs.Random.string('lower', 10);
console.log(randomString);


// 生成一个随机中文名
const randomChineseName = mockjs.Random.name();
console.log(randomChineseName);


// 生成一个随机地址
const randomAddress = mockjs.Random.region();
console.log(randomAddress);

// 生成一个随机日期
const randomDate = mockjs.Random.date();
console.log(randomDate);

// // 生成一个随机时间戳
// const randomTimestamp = mockjs.Random.timestamp();
// console.log(randomTimestamp);

// 生成一个随机邮箱
const randomEmail = mockjs.Random.email();
console.log(randomEmail);


// 生成一个随机UUID
const randomUUID = mockjs.Random.uuid();
console.log(randomUUID);

// 生成一个随机图片URL
const randomImgUrl = mockjs.Random.image('200x100', '#000', 'Hello Mock.js');
console.log(randomImgUrl);

// 生成一个随机时间字符串
const randomTimeString = mockjs.Random.time('T');
console.log(randomTimeString);

// 生成一个随机日期字符串
const randomDateString = mockjs.Random.date();
console.log(randomDateString);

// // 生成一个随机邮箱字符串
const randomEmailString = mockjs.Random.email();
console.log(randomEmailString);

// // 生成一个随机IP地址字符串
const randomIPString = mockjs.Random.ip();
console.log(randomIPString);


// // 生成一个随机ID字符串
const randomIDString = mockjs.Random.id();
console.log(randomIDString);

// // 生成一个随机颜色值字符串
const randomColorValueString = mockjs.Random.color();
console.log(randomColorValueString);

// // 生成一个随机图片URL字符串

const randomImgUrlString = mockjs.Random.image('200x100', '#000', 'Hello Mock.js');
console.log(randomImgUrlString);

// // 生成一个随机时间字符串数组
const randomTimeStringArray = mockjs.Random.time('T', 10);
console.log(randomTimeStringArray);


// // 生成一个随机邮箱字符串数组
const randomEmailStringArray = mockjs.Random.email(10);
console.log(randomEmailStringArray);

// // 生成一个随机IP地址字符串数组
const randomIPStringArray = mockjs.Random.ip(10);
console.log(randomIPStringArray);
